//
//  SuggestViewController.m
//  NewChat
//
//  Created by 马欢 on 16/2/27.
//  Copyright © 2016年 蓝鸥. All rights reserved.
//

#import "SuggestViewController.h"

@interface SuggestViewController ()<UITextViewDelegate>
@property (nonatomic,strong)UILabel *uilabel;
@property (nonatomic,strong)UIImageView *backgroundView;
@end


@implementation SuggestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //   背景图片
    self.backgroundView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
    self.backgroundView.image = [UIImage imageNamed:@"suggest.jpg"];
    [self.view addSubview:self.backgroundView];
    //  创建需要的毛玻璃特效类型
    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    //  毛玻璃view 视图
    UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    //添加到要有毛玻璃特效的控件中
    effectView.frame = self.backgroundView.bounds;
    //设置模糊透明度（范围0到1）
    effectView.alpha = 0.5f;
    [self.backgroundView addSubview:effectView];
    [self.view sendSubviewToBack:effectView];
    [self.view sendSubviewToBack:self.backgroundView];
    // Do any additional setup after loading the view.
    self.title = @"意见反馈";
    self.edgesForExtendedLayout = UIRectEdgeBottom;
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"取消" style:(UIBarButtonItemStylePlain) target:self action:@selector(backAction:)];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"提交" style:(UIBarButtonItemStylePlain) target:self action:@selector(backAction:)];
//    初始化UITextView
    //首先定义UITextView
    UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(0, 10, [UIScreen mainScreen].bounds.size.width, 160)];
    textView.font = [UIFont systemFontOfSize:20];
    textView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:textView];
    textView.hidden = NO;
    textView.delegate = self;
    //其次在UITextView上面覆盖个UILable,UILable设置为全局变量
    self.uilabel = [[UILabel alloc]init];
    self.uilabel.frame =CGRectMake(5, 10, [UIScreen mainScreen].bounds.size.width, 40);
    self.uilabel.font = [UIFont systemFontOfSize:20];
    self.uilabel.text = @"   有什么不爽的，马上吐槽吧～";
    self.uilabel.enabled = NO;//lable必须设置为不可用
    self.uilabel.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.uilabel];
}
//    实现UITextView的代理
-(void)textViewDidChange:(UITextView *)textView
{
        if (textView.text.length == 0) {
            self.uilabel.text = @"有什么不爽的，马上吐槽吧～";
        }else{
            self.uilabel.text = @"";
        }
}
//view将要出现 给背景色 tabbar隐藏
-(void)viewWillAppear:(BOOL)animated{
//    self.view.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
    [self.tabBarController.tabBar setHidden:YES];
}
//返回上一层
-(void)backAction:(UIBarButtonItem *)sender{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
